package com.shop.cereshop.agent.dao.referral;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.agent.page.referral.AgentGetIncomeVO;
import com.shop.cereshop.agent.page.referral.AgentShopDetailVO;
import com.shop.cereshop.agent.page.referral.AgentShopOrderDetailVO;
import com.shop.cereshop.agent.page.referral.AgentShopVO;
import com.shop.cereshop.agent.page.referral.AgentShopsVO;
import com.shop.cereshop.commons.domain.referral.AgentReferralRelation;
import com.shop.cereshop.agent.page.rank.RankItem;
import com.shop.cereshop.agent.param.rank.AgentRankDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AgentReferralDAO extends BaseMapper<AgentReferralRelation> {

  List<RankItem> getShopNum();

  RankItem getMyShopNum(AgentRankDTO param);

  List<RankItem> getUserNum();

  RankItem getMyUserNum(AgentRankDTO param);

  List<RankItem> getAgentNum();

  RankItem getMyAgentNum(AgentRankDTO param);

  List<RankItem> getSalespersonNum();

  RankItem getMySalespersonNum(AgentRankDTO param);

  List<RankItem> getShopAmount();

  RankItem getMyShopAmount(AgentRankDTO param);

  List<RankItem> getUserAmount();

  RankItem getMyUserAmount(AgentRankDTO param);

  /**
   * 一次性获取所有数量排行榜数据
   * 包括：商家数量榜、用户数量榜、代理商推广榜、业务员推广榜
   * 注意：此方法返回所有数据，分页需要在应用层处理
   *
   * @return 各类型排行榜数据列表
   */
  List<RankItem> getAllNumRankData();

  Long selectUserByInviteCode(@Param("inviteCode") String inviteCode);

  AgentGetIncomeVO getIncome(@Param("agentUserId") Long agentUserId);

  /**
   * 查询店铺列表
   */
  List<AgentShopVO> getShops(@Param("agentUserId") Long agentUserId,
      @Param("shopType") Integer shopType,
      @Param("search") String search,
      @Param("sort") Integer sort,
      @Param("timeRange") Integer timeRange);

  /**
   * 查询店铺总数和总分润（全局统计，不受类型和搜索影响）
   */
  AgentShopsVO getShopStatistics(@Param("agentUserId") Long agentUserId,
      @Param("timeRange") Integer timeRange);

  /**
   * 查询店铺基本信息
   */
  AgentShopDetailVO getShopBasicInfo(@Param("agentUserId") Long agentUserId,
      @Param("shopId") Long shopId);

  /**
   * 查询店铺订单列表
   */
  List<AgentShopDetailVO.ShopOrderVO> getShopOrders(@Param("shopId") Long shopId,
      @Param("month") String month);

  /**
   * 查询店铺订单详情
   */
  AgentShopOrderDetailVO getShopOrderDetail(@Param("agentUserId") Long agentUserId,
      @Param("orderId") Long orderId);

  /**
   * 查询订单商品列表
   */
  List<AgentShopOrderDetailVO.OrderGoodsVO> getOrderGoods(@Param("orderId") Long orderId);
}
